﻿using log4net.Repository;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace SJ.Platform.Common
{
    public class LogManager
    {
        /// <summary>
        /// 写信息
        /// </summary>
        /// <param name="loggerName"></param>
        /// <param name="info"></param>
        public static void WriteInfo(string loggerName, string info)
        {
            //return;
            LogManager.GetLogger(loggerName).Info(info);
        }
        /// <summary>
        /// 记录错误信息
        /// </summary>
        /// <param name="loggerName"></param>
        /// <param name="error"></param>
        public static void WriteError(string loggerName, Exception ex)
        {
            //return;
            LogManager.GetLogger(loggerName).Error(ex.Message + "   " + ex.StackTrace);
        }
        /// <summary>
        /// 记录调试信息
        /// </summary>
        /// <param name="loggerName"></param>
        /// <param name="debugMsg"></param>
        public static void WriteDubug(string loggerName, string debugMsg)
        {
            //return;
            LogManager.GetLogger(loggerName).Debug(debugMsg);
        }
        /// <summary>
        /// 记录至命信息
        /// </summary>
        /// <param name="loggerName"></param>
        /// <param name="FatalMsg"></param>
        public static void WriteFatal(string loggerName, string FatalMsg)
        {
            LogManager.GetLogger(loggerName, FatalMsg);
        }

        public static ILoggerRepository CreateRepository(string repository)
        {
            return log4net.LogManager.CreateRepository(repository);
        }
        public static ILoggerRepository CreateRepository(Type repositoryType)
        {
            return log4net.LogManager.CreateRepository(repositoryType);
        }
        public static ILoggerRepository CreateRepository(Assembly repositoryAssembly, Type repositoryType)
        {
            return log4net.LogManager.CreateRepository(repositoryAssembly, repositoryType);
        }
        public static ILoggerRepository CreateRepository(string repository, Type repositoryType)
        {
            return log4net.LogManager.CreateRepository(repository, repositoryType);
        }
        public static ILog Exists(string name)
        {
            return log4net.LogManager.Exists(name);
        }
        public static ILog Exists(Assembly repositoryAssembly, string name)
        {
            return log4net.LogManager.Exists(repositoryAssembly, name);
        }
        public static ILog Exists(string repository, string name)
        {
            return log4net.LogManager.Exists(repository, name);
        }
        public static ILoggerRepository[] GetAllRepositories()
        {
            return log4net.LogManager.GetAllRepositories();
        }
        public static ILog[] GetCurrentLoggers()
        {
            return log4net.LogManager.GetCurrentLoggers();
        }
        public static ILog[] GetCurrentLoggers(Assembly repositoryAssembly)
        {
            return log4net.LogManager.GetCurrentLoggers(repositoryAssembly);
        }
        public static ILog[] GetCurrentLoggers(string repository)
        {
            return log4net.LogManager.GetCurrentLoggers(repository);
        }
        public static ILog GetLogger(string name)
        {
            return log4net.LogManager.GetLogger(name);
        }
        public static ILog GetLogger(Type type)
        {
            return log4net.LogManager.GetLogger(type);
        }
        public static ILog GetLogger(Assembly repositoryAssembly, string name)
        {
            return log4net.LogManager.GetLogger(repositoryAssembly, name);
        }
        public static ILog GetLogger(Assembly repositoryAssembly, Type type)
        {
            return log4net.LogManager.GetLogger(repositoryAssembly, type);
        }
        public static ILog GetLogger(string repository, string name)
        {
            return log4net.LogManager.GetLogger(repository, name);
        }
        public static ILog GetLogger(string repository, Type type)
        {
            return log4net.LogManager.GetLogger(repository, type);
        }
        public static ILoggerRepository GetRepository()
        {
            return log4net.LogManager.GetRepository();
        }
        public static ILoggerRepository GetRepository(Assembly repositoryAssembly)
        {
            return log4net.LogManager.GetRepository(repositoryAssembly);
        }
        public static ILoggerRepository GetRepository(string repository)
        {
            return log4net.LogManager.GetRepository(repository);
        }
        public static void ResetConfiguration()
        {
            log4net.LogManager.ResetConfiguration();
        }
        public static void ResetConfiguration(Assembly repositoryAssembly)
        {
            log4net.LogManager.ResetConfiguration(repositoryAssembly);
        }
        public static void ResetConfiguration(string repository)
        {
            log4net.LogManager.ResetConfiguration(repository);
        }
        public static void Shutdown()
        {
            log4net.LogManager.Shutdown();
        }
        public static void ShutdownRepository()
        {
            log4net.LogManager.ShutdownRepository();
        }
        public static void ShutdownRepository(Assembly repositoryAssembly)
        {
            log4net.LogManager.ShutdownRepository(repositoryAssembly);
        }
        public static void ShutdownRepository(string repository)
        {
            log4net.LogManager.ShutdownRepository(repository);
        }
    }
}
